import {defineStore} from "pinia";
import dayjs from '@/utils/time'

export const useAppStore = defineStore('app', {
    persist: true, //使用持久化插件
    state: () => {   //是一个函数，返回一个对象，用于存储状态
        return {
            collapsed: true,
            theme: 'light',
            full: false,
            authModalShow: false,
            emailCodeTime: 1692693110
        }
    },
    getters: {
    },  //用于存储计算属性
    actions: {  //用于封装业务逻辑
        switchCollapsed() {
            this.collapsed = !this.collapsed
        },
        switchTheme() {
            if (this.theme === 'light') this.theme = 'dark'
            else this.theme = 'light'
        },
        startEmailCodeCount() {
            this.emailCodeTime = dayjs().unix()
        },
    },
})